<?php
session_start();
?>
<HTML>
<HEAD>
<TITLE>ESSA Salud - Datos del Afiliado</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1250">
<!-- ImageReady Preload Script (index.psd) -->
<SCRIPT TYPE="text/javascript">
<!--

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		about_us_over = newImage("images/about-us-over.gif");
		services_over = newImage("images/services-over.gif");
		our_stuff_over = newImage("images/our-stuff-over.gif");
		volunteers_over = newImage("images/volunteers-over.gif");
		preloadFlag = true;
	}
}

// -->
</SCRIPT>
<!-- End Preload Script -->
</HEAD>
<link href="css/styles.css" rel="stylesheet" type="text/css">
<center>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 ONLOAD="preloadImages();">
<!-- ImageReady Slices (index.psd) -->
<table width=789 border=0 cellpadding=0 cellspacing=0 class="frame">
  <tr>
    <td colspan=2 rowspan=4><img src="images/m1.gif" width=45 height=92 alt=""></td>
    <td colspan=9><img src="images/m2.gif" width=223 height=14 alt=""></td>
    <td colspan=9 rowspan=3><img src="images/m3.gif" width=305 height=68 alt=""></td>
    <td colspan=12 rowspan=2><img src="images/ic1.gif" width=215 height=34 alt=""></td>
    <td width="10"></td>
  </tr>
  <tr>
    <td colspan=9 rowspan=3><img src="images/title.gif" width=223 height=78 alt=""></td>
    <td><img src="images/spacer.gif" width=1 height=20 alt=""></td>
  </tr>
  <tr>
    <td colspan=2><img src="images/ic2.gif" width=19 height=34 alt=""></td>
    <td height=34 colspan=5 align="left" valign="top" background="images/b_ic1.gif"><a href="index.html" class="a">Inicio</a></td>
    <td width=52 height=34 align="left" valign="top" background="images/b_ic2.gif" ><a href="#" class="a">Ayuda</a></td>
    <td height=34 colspan=4 align="left" valign="top" background="images/b_ic3.gif" ><p><a href="#" class="a">Contactos</a></p></td>
    <td></td>
  </tr>
  <tr>
    <td width="124" rowspan=2><a href="about.html"
				> <img name="about_us" src="images/about-us.gif" width=124 height=40 border=0 alt="about us"></a></td>
    <td colspan=7 rowspan=2><a href="planes.html"
				> <img name="services" src="images/services.gif" width=121 height=40 border=0 alt="services"></a></td>
    <td colspan=6 rowspan=2><a href="formularios.html"
				> <img name="our_stuff" src="images/our-stuff.gif" width=121 height=40 border=0 alt="our stuff"></a></td>
    <td colspan=5 rowspan=2><a href="contactenos.php"
				> <img name="volunteers" src="images/volunteers.gif" width=123 height=40 border=0 alt="volunteers"></a></td>
    <td colspan=2 rowspan=2><img src="images/m4.gif" width=31 height=40 alt=""></td>
    <td><img src="images/spacer.gif" width=1 height=24 alt=""></td>
  </tr>
  <tr>
    <td colspan=11><img src="images/m5.gif" width=255 height=16 alt=""></td>
    <td><img src="images/spacer.gif" width=1 height=16 alt=""></td>
  </tr>
  <tr>
    <td colspan=32 rowspan=7><img src="images/cabecera.gif" width="775" height="294"></td>
    <td><img src="images/spacer.gif" width=1 height=118 alt=""></td>
  </tr>
  <tr>
    <td><img src="images/spacer.gif" width=1 height=19 alt=""></td>
  </tr>
  <tr>
    <td><img src="images/spacer.gif" width=1 height=39 alt=""></td>
  </tr>
  <tr>
    <td height="50"><img src="images/spacer.gif" width=1 height=50 alt=""></td>
  </tr>
  <tr>
    <td height="17"><img src="images/spacer.gif" width=1 height=17 alt=""></td>
  </tr>
  <tr>
    <td height="21"><img src="images/spacer.gif" width=1 height=21 alt=""></td>
  </tr>
  <tr>
    <td><img src="images/spacer.gif" width=1 height=30 alt=""></td>
  </tr>
  <tr>
    <td width="29" height="2"><img src="images/spacer.gif" width=27 height=1 alt=""></td>
    <td width="16"><img src="images/spacer.gif" width=15 height=1 alt=""></td>
    <td width="4"><img src="images/spacer.gif" width=4 height=1 alt=""></td>
    <td width="142"><img src="images/spacer.gif" width=136 height=1 alt=""></td>
    <td width="12"><img src="images/spacer.gif" width=11 height=1 alt=""></td>
    <td width="16"><img src="images/spacer.gif" width=15 height=1 alt=""></td>
    <td width="1"><img src="images/spacer.gif" width=1 height=1 alt=""></td>
    <td width="15"><img src="images/spacer.gif" width=14 height=1 alt=""></td>
    <td width="18"><img src="images/spacer.gif" width=17 height=1 alt=""></td>
    <td width="3"><img src="images/spacer.gif" width=3 height=1 alt=""></td>
    <td width="12"><img src="images/spacer.gif" width=12 height=1 alt=""></td>
    <td><img src="images/spacer.gif" width=124 height=1 alt=""></td>
    <td width="11"><img src="images/spacer.gif" width=11 height=1 alt=""></td>
    <td width="3"><img src="images/spacer.gif" width=3 height=1 alt=""></td>
    <td width="16"><img src="images/spacer.gif" width=16 height=1 alt=""></td>
    <td width="16"><img src="images/spacer.gif" width=16 height=1 alt=""></td>
    <td width="32"><img src="images/spacer.gif" width=32 height=1 alt=""></td>
    <td width="20"><img src="images/spacer.gif" width=20 height=1 alt=""></td>
    <td width="23"><img src="images/spacer.gif" width=23 height=1 alt=""></td>
    <td width="60"><img src="images/spacer.gif" width=60 height=1 alt=""></td>
    <td width="13"><img src="images/spacer.gif" width=13 height=1 alt=""></td>
    <td width="6"><img src="images/spacer.gif" width=6 height=1 alt=""></td>
    <td width="6"><img src="images/spacer.gif" width=6 height=1 alt=""></td>
    <td width="9"><img src="images/spacer.gif" width=9 height=1 alt=""></td>
    <td width="27"><img src="images/spacer.gif" width=27 height=1 alt=""></td>
    <td width="10"><img src="images/spacer.gif" width=10 height=1 alt=""></td>
    <td width="5"><img src="images/spacer.gif" width=5 height=1 alt=""></td>
    <td><img src="images/spacer.gif" width=52 height=1 alt=""></td>
    <td width="44"><img src="images/spacer.gif" width=44 height=1 alt=""></td>
    <td width="12"><img src="images/spacer.gif" width=12 height=1 alt=""></td>
    <td width="4"><img src="images/spacer.gif" width=4 height=1 alt=""></td>
    <td width="27"><img src="images/spacer.gif" width=27 height=1 alt=""></td>
    <td></td>
  </tr>
</table>

<p><br>
<?php
include ("class/class.webservice.php");

$webservice = new WebService();

if ($_SESSION['logueado'] == 'si')
{
	$dniafiliado = $_SESSION['afiliadodni'];
	$afiliado = $webservice->ObtenerDatosUsuario($dniafiliado);
}
else
{
	if($_POST["usuario"] != null || $_POST["clave"] != null)
	{
		$dniafiliado = $webservice->ObtenerDniUsuario($_POST["usuario"], $_POST["clave"]);
		
		if ($dniafiliado == "error")
		{
			echo "Usuario o password incorrectos";
		}
		else
		{
			$_SESSION['logueado'] = 'si';
			$_SESSION['afiliadodni'] = $dniafiliado;
			$afiliado = $webservice->ObtenerDatosUsuario($dniafiliado);
		}
	}
	else
	{
		echo "Debe ingresar un nombre de usuario y una contrasena";
	}
}

//--------------------------------------------
//Mostramos los datos del Afiliado

if($afiliado != null) 
{
	foreach ($afiliado as $row) printf ("<br><h2>Afiliado: %s, %s</h2><ul><br>", $row["afiliadoapellido"], $row["afiliadonombre"]); 
	
	//Aqui se dibuja el menu con las opciones para el afiliado
	echo "<table border=2><tr>";
	echo "<td bgcolor='#666666' width='90' align='center'><p><a href='estado.php' class='a'>Principal</a></p></td>";
	echo "<td bgcolor='#666666' width='170' align='center'><p><a href='editardatos.php' class='a'>Modificar datos personales</a></p></td>";
	echo "<td bgcolor='#666666' width='170' align='center'><p><a href='estadocuenta.php' class='a'>Consultar Estado de Cuenta</a></p></td>";
	echo "<td bgcolor='#666666' width='90' align='center'><p><a href='login.php?salir=si' class='a'>Salir</a></p></td>";	
	echo "</tr></table><br>";	
	echo "<table width='600' border='1' valign='top'><tr><td>";	
	echo "<h4>Datos Personales</h4><ul>";
	
	
	foreach($afiliado as $row) 
	{ 
		printf("<li><strong>Nombre: %s</strong></li>", $row["afiliadonombre"]); 
		printf("<li><strong>Apellido: %s</strong></li>", $row["afiliadoapellido"]);
		printf("<li><strong>DNI: %s</strong></li>", $row["afiliadodni"]);
		printf("<li><strong>Domicilio: %s</strong></li>", $row["afiliadodomicilio"]);
		printf("<li><strong>Email: %s</strong></li>", $row["afiliadoemail"]);
		if ($row["afiliadosexo"] == M)
		{
			printf("<li><strong>Sexo: Masculino</strong></li>");
		}
		else
		{
			printf("<li><strong>Sexo: Femenino</strong></li>");
		}
	} 
	echo "</ul></td>"; 


//--------------------------------------------
//Mostramos los datos del Plan del Afiliado

echo "<td VALIGN='top'>";
	
	echo "<h4>Datos del Plan</h4><ul>";
	
	foreach($afiliado as $row) 
	{ 
		printf("<li><strong>Plan contratado: %s</strong></li>", $row["plandesc"]); 
		printf("<li><strong>Importe mensual: %s</strong></li>", $row["planmonto"]);
		printf("<li><strong>Monto extra por familiar: %s</strong></li>", $row["planextrafamiliar"]);
	} 
	echo "</ul></td></tr>"; 

echo "</table>";

}



?>
  
  </p>
<p><br>
  <!-- End ImageReady Slices -->
  <img src="images/marco-inferior.PNG" width="776" height="74"></p>
</BODY>
</center>
</HTML>